package com.eden.door.view;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JPanel;

import com.eden.door.context.AppContext;
import com.eden.door.entity.Door;
import com.eden.door.listener.JbtListener;

public class DoorButtonsPanel extends JPanel {
	private static final long serialVersionUID = 1L;
	private JButton jbtDoor;
	/**
	 * Create the panel.
	 */
	public DoorButtonsPanel(MainView mainView) {
		List<Door> doorList = AppContext.instance().getDoorList() ;
		JbtListener doorButtonListenter = new JbtListener(mainView) ;
		
		setLayout(new FlowLayout(FlowLayout.CENTER, 10, 100));
		// 根据门的种类加入相应按钮
		for (int i = 0; i < doorList.size(); i++) {
			jbtDoor = new JButton(doorList.get(i).getName());
			jbtDoor.setPreferredSize(new Dimension(80, 50)) ;
			add(jbtDoor);

			jbtDoor.addActionListener(doorButtonListenter);
		}
	}

}
